<script setup>
import { onBeforeMount,ref } from "vue";
import {useRouter} from 'vue-router'
import { GetmineCourseapi } from "../../http/api";
import ItemBox from "../../components/Home/ItemBox.vue";
const Coursedoing=ref([])
const router=useRouter()
const GetDate = () => {
  var a = new Date().getTime();
  var b = new Date(a);

  function nowDate(now) {
    var yaer = now.getFullYear();
    var month = now.getMonth() + 1;
    return yaer + "年" + month + "月";
  }
  return nowDate(b);
};
onBeforeMount(() => {
  GetDate();
  getminecourse()
});
const getminecourse=()=>{
   GetmineCourseapi().then((res)=>{
    console.log(res);
    Coursedoing.value=res.data.data.slice(0,1)
   })
}
</script>
<template>
  <div>
    <div class="_new_date_box">
      <h1>{{ GetDate() }}</h1>
    </div>
    <div class="_new_date_box_two"></div>
    <div class="_new_date_box_course_day">
        <div class="_new_date_box_today">
            <div class="aside">今日课程(0节)</div>
            <div class="asidelo" @click="router.push('/coursechart')">
                <van-icon name="calendar-o" size="25" />
                <div>课表</div>
            </div>
        </div>
    </div>
    <div class="_new_date_box_course_tab">
        <div class="_new_date_box_course_tab_list" @click="router.push('/studyrecord')">
            <img src="https://wap.lexuemiao.com/img/history-full@3x.fd48535a.png" alt="">
            <div>学习记录</div>
        </div>
        <div class="_new_date_box_course_tab_list" @click="router.push('/studyinfo')">
            <img src="https://wap.lexuemiao.com/img/ziliao@3x.6d7c3da4.png" alt="">
            <div>学习资料</div>
        </div>
    </div>
    <div class="_mine_course_list">
            <div class="_mine_course_doing_stydy" v-show="Coursedoing">
                <div class="_mine_course_doing_head">
                    <div class="one">正在学习的课程</div>
                    <div class="two" @click="router.push('/seecourse')">查看更多<van-icon name="arrow" /></div>
                </div>
                <item-box :data="Coursedoing" :show="true"></item-box>
            </div>
            <div v-show="!Coursedoing">
                <van-empty description="暂无课程记录" />
            </div>
    </div>
  </div>
</template>
<style scoped>
._new_date_box {
  width: 100%;
  height: 100px;
  line-height: 30px;
  text-align: left;
  background-color: white;
  position: fixed;
  top: 0;
}
._mine_course_doing_head{
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left:30px;
    padding-right: 30px;
    box-sizing: border-box; 
}
._mine_course_doing_head .one{
    font-weight: 800;
}
._mine_course_doing_head .two{
    font-size: 26px;
    color: #ccc;
}
._new_date_box_two {
  width: 100%;
  height: 140px !important;
  line-height: 30px;
  text-align: left;
  background-color: wheat;
  margin-top: 100px;
}
._new_date_box_course_day{
    height: 120px;
    width: 100%;
}
._new_date_box_today{
    width: 80%;
    height: 90%;
    background-color: #f5f6f8;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.asidelo{
    display: flex;
    width: 100px;
    height: 80px;
    flex-wrap: wrap;
    text-align: center;
    align-items: center;
    justify-content: center;
}
._new_date_box_course_tab{
    width: 100%;
    height: 220px;
    /* background-color: white; */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 100px;box-sizing: border-box;
    padding-right: 100px;
}
._new_date_box_course_tab_list img{
    width: 90px;
    height: 90px;
}
._new_date_box_course_tab_list{
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    align-content: center;
    font-size: 26px;
    width: 150px;
    height: 100%;
    color: #607ab0;
    font-weight: 600
}
._mine_course_doing_stydy{
    width: 100%;
    height: 100%;
    background-color: #f5f6f8;
}
</style>
